import { fromJS } from 'immutable'
import { USERCHANGE, USERAVATAR } from '../actionType'

const initialState = fromJS({
  obj: {}
})

export default (state = initialState, { type, payload }) => {
  switch (type) {
    case USERCHANGE:
      return state.set('obj', payload)
    case USERAVATAR:
      return state.setIn(['obj', 'avatar'], payload)
    default:
      return state
  }
}
